package com.kalix.btzjjj.txt.biz;

import com.kalix.btzjjj.txt.api.biz.ITotalFlowBeanService;
import com.kalix.btzjjj.txt.api.dao.ITotalFlowBeanDao;
import com.kalix.btzjjj.txt.api.model.InfUtil;
import com.kalix.btzjjj.txt.api.model.ReadFileUtil;
import com.kalix.btzjjj.txt.entities.TotalFlowBean;
import com.kalix.framework.core.impl.biz.GenericBizServiceImpl;
import com.kalix.framework.core.util.ConfigUtil;
import org.json.JSONArray;
/**
 *@ Author  ZhaoHang
 * @Date  2019/8/28
 **/
public class TotalFlowBeanServiceImpl extends GenericBizServiceImpl<ITotalFlowBeanDao, TotalFlowBean> implements ITotalFlowBeanService {
    String txtIp = (String) ConfigUtil.getConfigProp("FREEBOARD_TXT_IP","config.btzjjj.portconf");
    @Override
    public String getValue() {
//        JSONArray jArray = ReadFileUtil.ReadFileUtil();
        String last = "";
        String str = InfUtil.interfaceUtil(txtIp,"");
        String key = str.substring(0, 304);
        String all = str.substring(304, str.length());
        String[] name = key.split(",");
        String[] value = all.split(",");
        String dayFlow = null;
        String weekFlow = null;
        String monthFlow = null;
        for (int i = 0; i < name.length; i++) {
            if ("dayFlow".equals(name[i])) {
                dayFlow = value[i];
            }
            if ("weekFlow".equals(name[i])) {
                weekFlow = value[i];
            }
            if ("monthFlow".equals(name[i])) {
                monthFlow = value[i];
        }
        }
        last = "{" +
                "\"yData\": [\"本日流量总合\",\"本周流量总合\",\"本月流量总合\"]," +
                "\"data\": [\"" + dayFlow + "\",\"" + weekFlow + "\",\"" + monthFlow + "\"]" +
                "}";
        return last;
    }
}
